/* Serial_Thor: Serial I/O message processing and dispatch.
     * All macros are defined here and dispatched as needed.
*/

#include <Arduino.h>
#include <string.h>

// HandleMessage:
void HandleMessage(String sMsg) {
  if(sMsg == "") {return;}  // Nothing found, so this msg is discarded
//  else if(sMsg == "MUTE") {delay(100); pinMode(13,OUTPUT); digitalWrite(13,HIGH);}
/*DisableAll();}
  else if(sMsg == "ALL_ON") {EnableAll();}
  else if(sMsg == "GET_T1") {Serial.print}*/
}

void getMessage() {
  String msg=""; byte ch; byte d='#';

  if(Serial.available()) {
    while(Serial.available() && Serial.peek()!=d) {
      ch=Serial.read();
      msg+=(char)ch;
      delay(1);  // wait for the next character
    }
    ch=Serial.read();// pop the '#' from the buffer
    if(ch==d) {HandleMessage(msg); return;}
  }
}
